package com.zzz.framework.config.mybatis;

import com.mybatisflex.annotation.UpdateListener;
import com.zzz.framework.model.BaseDO;
import com.zzz.framework.util.LoginInfoUtil;

import java.time.LocalDateTime;

public class MyUpdateListener implements UpdateListener {
    @Override
    public void onUpdate(Object entity) {
        if (entity instanceof BaseDO) {
            //设置 account 被新增时的一些默认数据
            BaseDO baseDO = (BaseDO)entity;
            baseDO.setUpdateTime(LocalDateTime.now());
            baseDO.setUpdater(LoginInfoUtil.getLoginId());
        }
    }
}
